package cn.cwkizq.springmvctest.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/demo")
public class DemoController {
	@ResponseBody
	@RequestMapping(value="/test")
	/**
	 * url:http://localhost:8080/springmvctest-web/demo/test
	 * */
	public String test() {
		return "hello world";
	}
	@ResponseBody
	@RequestMapping(value="/getOrder")
	/**
	 * url:http://localhost:8080/springmvctest-web/demo/getOrder
	 * */
	public Order getOrder(){
		Order order = new Order("4324343434",345d);
		return order;
	}
	
	@ResponseBody
	@RequestMapping(value="/sayhello", params="param1=value1")
	/**
	 * http://localhost:8080/springmvctest-web/demo/sayhello?param1=value1
	 * */
	public String sayhello() {
		return "sayhello hello!";
	}
	@ResponseBody
	@RequestMapping(value="/sayhello2", params="param1")
	/**
	 * http://localhost:8080/springmvctest-web/demo/sayhello2?param1=123
	 * 只要参数中包含param1即可访问，值和参数个数没有限制
	 * */
	public String sayhello2() {
		return "sayhello2 hello!";
	}
	@ResponseBody
	@RequestMapping(value="/sayhello3", params="!param1")
	/**
	 * http://localhost:8080/springmvctest-web/demo/sayhello3?param3333=123
	 * 只要参数中不包含param1即可访问，值和参数个数没有限制
	 * */
	public String sayhello3() {
		return "sayhello3 hello!";
	}
	
	@ResponseBody
	@RequestMapping(value="/order/{orderid}")
	/**
	 * url:http://localhost:8080/springmvctest-web/demo/order/4134243434
	 * */
	public String getOrderByOrderId(@PathVariable String orderid){
		return "result order:"+orderid;
	}
	
	@ResponseBody
	@RequestMapping(value="/queryOrder")
	/**
	 * http://localhost:8080/springmvctest-web/demo/queryOrder?shipid=111113443&profileid=5000
	 * */
	public String queryOrder(String shipid,String profileid){
		return "request params: shipid="+shipid+" profileid="+profileid;
		
	}
	
	
}
